﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;

namespace SkiPathStandalone
{
    public partial class frmProfile : Form
    {
        public frmProfile()
        {
            InitializeComponent();
        }

        private void frmProfile_Load(object sender, EventArgs e)
        {
            // Setup the graph
            CreateGraph(zedProfileGraph);//zedProfileGraph
            // Size the control to fill the form with a margin
            SetSize();
        }
        // SetSize() is separate from Resize() so we can 
        // call it independently from the Form1_Load() method
        // This leaves a 10 px margin around the outside of the control
        // Customize this to fit your needs
        private void SetSize()
        {
            zedProfileGraph.Location = new Point(10, 10);
            // Leave a small margin around the outside of the control
            zedProfileGraph.Size = new Size(ClientRectangle.Width - 20,
                                    ClientRectangle.Height - 20);
        }
        // Build the Chart
        private void CreateGraph(ZedGraphControl zg1)
        {
            // Get a reference to the GraphPane
            GraphPane myPane = zg1.GraphPane;
            // Set the titles
            myPane.Title.Text = "Profile Screen";
            myPane.XAxis.Title.Text = "Route Length";
            myPane.YAxis.Title.Text = "Elevation";

            double x, y;
            PointPairList list = new PointPairList();
            for (int i = 0; i < SkiPathStandalone.ProfileCreator.table.Rows.Count; i++)
            {
                x = Convert.ToDouble(SkiPathStandalone.ProfileCreator.table.Rows[i][0].ToString());
                y = Convert.ToDouble(SkiPathStandalone.ProfileCreator.table.Rows[i][1].ToString());
                list.Add(x, y);
            }
            CurveItem myCurve = myPane.AddCurve("Velocity of Elevation by Routh Length",
                  list, Color.Blue, SymbolType.Triangle);
            myPane.Chart.Fill = new Fill(Color.White,
                Color.FromArgb(255, 255, 210), -45F);
            zg1.AxisChange();
        }

        private void frmProfile_Resize(object sender, EventArgs e)
        {
            SetSize();
        }
    }
}
